<script type="text/javascript">
	function doSearchTransOrder(value) {
		
	}
	
	//表格查询  
	function reloadTransOrder() {
		var params = transOrder_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		transOrder_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		transOrder_list.datagrid('unselectAll');
		transOrder_list.datagrid('uncheckAll');
	}


	function addTransOrder() {
// 		createFromWindow("新增信息", "transOrder.do?editTransOrder", "transOrder.do?saveTransOrder",
// 				function(data) {
// 					reloadTransOrder();
// 				});
		
		createFromAutoSubmitWindow({
				title:"新增信息",
				maximizable:true,
				width:1350,
				height:520,
				href:"transOrder.do?editTransOrder",
				submitUrl:"transOrder.do?saveTransOrder",
				callback:function(data) {
					reloadTransOrder();
				},
				enableSaveButton:true
			});
	}
	
	function deleteTransOrder() {
		var rows = transOrder_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('transOrder.do?deleteTransOrderItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadTransOrder();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editTransOrder() {
		var rows = transOrder_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
// 			createFromWindow("编辑信息", "transOrder.do?editTransOrder&transOrderId=" + rows[0].id,
// 					"transOrder.do?saveTransOrder", function(data) {
// 						reloadTransOrder();
// 					},true);
			createFromAutoSubmitWindow({
				title:"编辑信息",
				maximizable:true,
				width:1350,
				height:520,
				href:"transOrder.do?editTransOrder&transOrderId=" + rows[0].id,
				submitUrl:"transOrder.do?saveTransOrder",
				callback:function(data) {
					reloadTransOrder();
				},
				enableSaveButton:rows[0].orderStatus=='1'
			});
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookTransOrder(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = transOrder_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
// 			createFromWindow("查看信息", "transOrder.do?editTransOrder&transOrderId=" + id,
// 					null, null,false);
			createFromAutoSubmitWindow({
				title:"查看信息",
				maximizable:true,
				width:1350,
				height:520,
				href:"transOrder.do?editTransOrder&transOrderId=" + id,
				submitUrl:"transOrder.do?saveTransOrder",
				callback:function(data) {
					reloadTransOrder();
				},
				enableSaveButton:false
			});
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditTransOrder(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = transOrder_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromAutoSubmitWindow({
				title:"查看信息",
				maximizable:true,
				width:1350,
				height:520,
				href:"transOrder.do?editTransOrder&transOrderId=" + id,
				submitUrl:"transOrder.do?saveTransOrder",
				callback:function(data) {
					reloadTransOrder();
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendTransOrder() {
		printLog('发送');
	}
	
	function operationsDeleteTransOrder(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('transOrder.do?deleteTransOrderItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadTransOrder(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearTransOrderSearch() {
		setGridSearchParams('transOrder_list','transOrderSearchForm',true,reloadTransOrder);
	}
	
	//根据条件查询
	function transOrderSearch() {
		setGridSearchParams('transOrder_list','transOrderSearchForm',false,reloadTransOrder);
	}
	
	function checkTransOrder() {
		var rows = transOrder_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
           	var ids = "";
           	for(var i=0; i<rows.length; i++){
           		ids += rows[i].id+",";
           	}
           	//jmaxAjax
            $.post('transOrder.do?checkTransOrderItems',{ids:ids},function(result){
                if (result.success){
                	reloadTransOrder();    
                }
                showMsg(result.msg,3000);
            },'json');
	    }else {
	    	showMsg("请选择操作记录.");
	    }
		
	}
	
	function cancleCheckTransOrder() {
		var rows = transOrder_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
           	var ids = "";
           	for(var i=0; i<rows.length; i++){
           		ids += rows[i].id+",";
           	}
           	//jmaxAjax
            $.post('transOrder.do?cancleCheckTransOrderItems',{ids:ids},function(result){
                if (result.success){
                	reloadTransOrder();    
                }
                showMsg(result.msg);
            },'json');
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
</script>

<#assign operations = "[\{shiro:'trans:transOrder:refresh',onClick:'operationsLookTransOrder',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'trans:transOrder:edit',onClick:'operationsEditTransOrder',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'trans:transOrder:delete',onClick:'operationsDeleteTransOrder',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="transOrder_list" toolbar="#transOrderlist_search" idField="id" operations="${operations!}"
			 url="transOrder.do?loadList&creator=${(user.loginName)!}" rownumbers="true"
			 item="com.xdtech.trans.vo.TransOrderItem"/>
		
		<div id="transOrderlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="transOrderSearchForm">
					<table>
						<tr>
							<td class="tbLabel">运单号：</td>
							<td><input class="easyui-validatebox textbox" name="orderNo" style="width: 150px" /></td>
							<td class="tbLabel">状态：</td>
							<td>
								<@eu.comboBox name="orderStatus" url="common.do?loadComboBox&key=ORDER_STATUS" />
							</td>
							<td class="tbLabel">接单时间从：</td>
							<td>
								<input name="receiveTimeForm"  class="easyui-datetimebox" />
							</td>
							<td class="tbLabel">接单时间到：</td>
							<td>
								<input name="receiveTimeEnd"  class="easyui-datetimebox" />
							</td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="transOrderSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearTransOrderSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="transOrder_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="trans:transOrder:add" iconCls="icon-add" onclick="addTransOrder()"/>
				<@eu.linkbutton showName="删除" shiro="trans:transOrder:delete" iconCls="icon-remove" onclick="deleteTransOrder()"/>
				<@eu.linkbutton showName="编辑" shiro="trans:transOrder:edit" iconCls="icon-edit" onclick="editTransOrder()"/>
				<@eu.linkbutton showName="审核通过" shiro="trans:transOrder:check" iconCls="icon-remove" onclick="checkTransOrder()"/>
				<@eu.linkbutton showName="取消审核" shiro="trans:transOrder:cancleCheck" iconCls="icon-edit" onclick="cancleCheckTransOrder()"/>
				<@eu.linkbutton showName="刷新" shiro="trans:transOrder:refresh" iconCls="icon-reload" onclick="reloadTransOrder()"/>
				
			</div>
		</div>
	</div>
</div>